﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using MS.Common;
using Prism.Commands;
using Prism.Events;
using Unity;
using Prism.Unity;
using Prism.Ioc;
using Prism.Regions;
using wpf.Triage.Views;
using System.Windows.Controls;
using System.Windows.Media;
using Prism.Services.Dialogs;

namespace wpf.Triage
{

    public class TriageViewModel : VmBase, INavigationAware
    {
        internal TriageBase Uc;

        public DelegateCommand<object> TriageNavCommand { get; private set; }
        public DelegateCommand<object> PatListCommand { get; private set; }


        private IDialogService dialogservice;
        public TriageViewModel(IContainerExtension container, IEventAggregator eventAggregator, IRegionManager regionManager, IDialogService dialogService) : base(container, eventAggregator, regionManager)
        {
            this.TriageNavCommand = new DelegateCommand<object>(OnTriageNavCommand);
            this.PatListCommand = new DelegateCommand<object>(OnPatListCommand);
            this.dialogservice = dialogService;
        }
        /// <summary>
        /// 点击左上角导航按钮
        /// </summary>
        /// <param name="obj"></param>
        private void OnTriageNavCommand(object obj)
        {
            string type = obj.ToString();
            Uri uri = null;
            switch (type)
            {
                case "1":
                case "2":
                    uri = new Uri(nameof(TriageRegisterView) + "?Type=" + type, UriKind.Relative);
                    break;
                case "4":
                    uri = new Uri(nameof(TriageWebView), UriKind.Relative);
                    break;
                default:
                    break;
            }
            if(uri!=null)
              regionManager.RequestNavigate(RegionName.TriageRegionName, uri);
        }
        private void OnPatListCommand(object obj)
        {
            //UserControl content = container.Resolve<PatientList>();
            //ModalHelper.ShowMDiag( Window.GetWindow(Uc), content, "患者列表",400,400);
            IDialogParameters parameters = new DialogParameters();
            parameters.Add("type","1");

            dialogservice.ShowDialog("PatientList", parameters,null);
        }

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {

        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {   //第一次进来进入分诊
            var uri = new Uri(nameof(TriageRegisterView), UriKind.Relative);
            regionManager.RequestNavigate(RegionName.TriageRegionName, uri);
        }
    }
}
